{layout name="public/layout" /}
{include file='yxnavbar'}


<div class="main">
    {include file='sms/sms_header'}
    <div class="panel panel-info">
        <div class="panel-heading">筛选 共{$total}个
            <span style="color: red;font-weight: bold;font-size: 16px;">
                {if $open_yx_sms==1}
<!--                【 成功发送 {$used_sms} 条 ，消费 {$used_amount} 元】-->
                {else}
                 【 短信通知未开通 】 开通请到 "群发短信" => "短信配置" 中开启，如有疑问请联系客服！
                {/if}
            </span>
        </div>
        <div class="panel-body">
            <form action="./index.php" method="get" class="form-horizontal" role="form">
                <input type="hidden" name="c" value="site"/>
                <input type="hidden" name="a" value="entry"/>
                <input type="hidden" name="m" value="{$_P['m']}"/>
                <input type="hidden" name="do" value="{$do}"/>
                <input type="hidden" name="ac" value="search"/>
                <input type="hidden" name="themeid" value="{$themeid}"/>
                {if $tradeId =='000000000000000000000'||!$tradeId}
                <div class="form-group">
                    <label class="col-xs-1 col-sm-1 col-md-1 control-label">场景</label>
                    <div class="col-xs-11 col-sm-9 col-md-9">
                        <div class="btn-group">
                            {loop $template_list $row}
                                {if $row['total']>0}
                                <a href="{php echo createWebUrl('sms',array('op' => 'display','themeid'=>$themeid,'type'=>$row['type']));}"
                                   class="btn {if $type == $row['type']}btn-primary{else}btn-default{/if}">
                                    {$row['name']}
                                    <span style="color: #ff0000">{$row['total']}</span>
                                </a>
                                {/if}
                            {/loop}
                        </div>
                    </div>
                </div>
                {/if}
                <div class="form-group">
                    <label class="col-xs-1 col-sm-1 col-md-1 control-label">发送状态</label>
                    <div class="col-xs-11 col-sm-9 col-md-9">
                        <div class="btn-group">
                            {loop $status_list $row}
                            <a href="{php echo createWebUrl('sms',array('op' => 'display','themeid'=>$themeid,'status'=>$row['status'],'tradeId'=>$tradeId));}"
                               class="btn {if $status == $row['status']}btn-primary{else}btn-default{/if}">
                                {$row['name']}
                                <span style="color: #ff0000">{$row['total']}</span>
                            </a>
                            {/loop}
                        </div>
                    </div>
                </div>
                {if $_G['isSuperAdmin']}
                <!--                <div class="form-group">-->
                <!--                    <label class="col-xs-1 col-sm-1 col-md-1 control-label">送达状态</label>-->
                <!--                    <div class="col-xs-11 col-sm-9 col-md-9">-->
                <!--                        <div class="btn-group">-->
                <!--                            {loop $trade_status_list $row}-->
                <!--                            <a href="{php echo createWebUrl('sms',array('op' => 'display','themeid'=>$themeid,'trade_status'=>$row['trade_status']));}" class="btn {if $trade_status == $row['trade_status']}btn-primary{else}btn-default{/if}">-->
                <!--                                {$row['name']}-->
                <!--                                <span style="color: #ff0000">{$row['total']}</span>-->
                <!--                            </a>-->
                <!--                            {/loop}-->
                <!--                        </div>-->
                <!--                    </div>-->
                <!--                </div>-->
                {/if}
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-1 control-label">关键字</label>
                    <div class="col-sm-9 col-xs-2 col-md-3">
                        <input class="form-control" name="search_data" placeholder="输入手机号、微信昵称、用户名、短信内容"
                               type="text" value="{$_P['search_data']}">
                    </div>
                    {if $status}
                    <input type="hidden" name="status" value="{$status}">
                    {/if}
                    {if $type}
                    <input type="hidden" name="type" value="{$type}">
                    {/if}
                    <div class="col-sm-3 col-lg-3 col-md-3 col-xs-6">
                        <button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
                        <input type="hidden" name="__token__" value="{$Request.token}"/>
                    </div>
                    <div class="col-sm-2 col-lg-2 col-md-2 col-xs-2">
                        {if $total<=5000}
                        <input class="btn btn-default" type="submit" name="export_submit" id="export_submit"
                               value="导出记录EXCEL">
                        {else}
                        <input class="btn btn-default" type="submit" name="export_submit" id="export_submit"
                               value="导出记录EXCEL(1-5000条)">
                        {/if}
                    </div>
                    {if $has_limit_sms>0}
                    <div class="col-sm-3 col-lg-3 col-md-3 col-xs-6">
                        <a href="{php echo createWebUrl('sms',array('op'=>'reissue','themeid'=>$themeid));}"
                           class="btn btn-success">短信补发</a>
                    </div>
                    {/if}
                </div>
<!--                <span class="help-block">短信按照每 67 个字符计费为一条短信，最长不超过350 个字符，短信长度计算：短信签名字数 + 短信模版实际发送内容字数。最终以实发短信长度为准。</span>-->
                {if $has_limit_sms>0}
                <span class="help-block" style="color: red;">系统存在待补发短信，如需发送请点击短信补发（活动编辑-短信-短信通知规则达到设定的上限，部分短信中断发送；请及时观察并修改合适设置）</span>
                {/if}
            </form>
        </div>
    </div>
    <div class="tab-content">
        <div class="panel panel-default">
            <div class="panel-body table-responsive">
                <table class="table table-hover">
                    <thead class="navbar-inner">
                    <tr>
                        <th style="width: 80px;">序号</th>
                        <th style="width: 80px;">头像昵称</th>
                        <th style="width: 100px;">场景</th>
                        <th style="width: 100px;">姓名电话</th>
                        <th style="width: 280px;">短信内容</th>
                        <th style="width: 80px;">短信字数</th>
                        <th style="width: 80px;">条数</th>
                        <th style="width: 80px;">计费</th>
                        <th style="width: 80px;">发送状态</th>

                        {if $_G['isSuperAdmin']}
                        <!--                        <th style="width: 80px;">送达状态</th>-->
                        {/if}
                        <th style="width: 80px;">备注</th>
                        <th style="width: 80px;">操作人</th>
                        <th style="width: 80px;">操作ip</th>

                        <th style="width: 140px;">创建时间</th>
                    </tr>
                    </thead>
                    <tbody>
                    {loop $list $item}
                    <tr>
                        <td>{$item['id']}</td>
                        <td>
                            {if $item['avatar']}<img src="{php echo tomedia($item['avatar']);}" width="28"
                                                     style="bsection-radius: 3px;"><br>{/if}{$item['nickname']}
                        </td>
                        <td>
                            <span class="label label-primary">
                                {if $item['type']=='diy'}
                                <?php $format_tmp_type = 'sms_diy_'.$item['templateId'];?>
                                {php echo $name_arr[$format_tmp_type];}
                                {else}
                                <?php $tmp_type = 'sms_'.$item['type']; ?>
                                {php echo str_replace('短信:','',$name_arr[$tmp_type]);}
                                {/if}

                            </span>
                        </td>
                        <td>{if $item['username']}{$item['username']}<br>{/if}{$item['mobile']}</td>

                        <td>{if $item['content']}【{php echo $brand;}】{/if}{$item['content']}
                        </td>
                        <td>
                            {php echo $item['sms_length'];}
                        </td>
                        <td>{$item['sms_num']}</td>
                        <td>{if $item['status']==1}{php echo $item['sms_num']/10;}{/if}</td>
                        <td>
                            {if $item['status']==1}
                            <span class="label label-success">发送成功</span>
                            {elseif $item['status']==4}
                            <span class="label label-warning">模版审核中</span>
                            {elseif $item['status']==5}
                            {if $item['try_num']>=3}
                            <span class="label label-danger">终止发送</span>
                            {else}
                            <span class="label label-warning">待发送，尝试次数{$item['try_num']}</span>
                            {/if}

                            <!--                            <span class="label label-warning">发送中断-静默用户</span>-->
                            {elseif $item['status']==2 || $item['status']==3}
                            <span class="label label-warning">发送失败</span>
                            {/if}
                            {if $item['status']==6}
                            <span class="label label-warning">发送中</span>
                            {/if}
                        </td>
                        {if $_G['isSuperAdmin']}
                        <!--                        <td>-->
                        <!--                            {if $item['status']==1}-->
                        <!--                            {if $item['trade_status']=='UNKNOW'}-->
                        <!--                            <span class="label label-primary">到达未知</span>-->
                        <!--                            {elseif $item['trade_status']=='DELIVRD'}-->
                        <!--                            <span class="label label-success">到达成功</span>-->
                        <!--                            {else}-->
                        <!--                            <span class="label label-warning">运营商拦截,到达失败</span>-->
                        <!--                            {/if}-->
                        <!--                            {else}-->
                        <!--                                {if $item['status']!=4}-->

                        <!--                                    {if $item['status']==5}-->
                        <!--                                        {if $item['try_num']>=3}-->
                        <!--                                        <span class="label label-danger">终止发送</span>-->
                        <!--                                        {else}-->
                        <!--                                        <span class="label label-warning">待发送</span>-->
                        <!--                                        {/if}-->
                        <!--                                    {else}-->
                        <!--                            <span class="label label-warning">未知状态</span>-->
                        <!--                                    {/if}-->
                        <!--                                {/if}-->
                        <!--                            {/if}-->
                        <!--                        </td>-->
                        {/if}
                        <td>
                            {if $item['status']==2 || $item['status']==3}
                            {if $item['trade_status']=='UNKNOW'}
                            <span class="label label-primary">到达未知</span>
                            {elseif $item['trade_status']=='DELIVRD'}
                            <span class="label label-success">到达成功</span>
                            {else}
                            <span class="label label-warning">运营商拦截,到达失败</span>
                            {/if}
                            {else}
                            {if $item['status']==1}
                            {elseif $item['status']==4}
                            {else}
                            {if $item['status']==5}
                            {if $item['try_num']>=3}
                            <span class="label label-danger">失败次数超过3次，终止发送</span>
                            {else}
                            <span class="label label-warning">待发送，尝试次数{php echo $item['try_num'];}</span>
                            {/if}
                            {else}
                            {if $item['status']==6}

                            {else}
                            <span class="label label-warning">未知状态</span>
                            {/if}
                            {/if}
                            {/if}
                            {/if}
                        </td>
                        <td>{php echo $item['admin_name']?$item['admin_name']:'系统发送';}</td>
                        <td>{$item['ip']}</td>

                        <td>
                            {if $item['status']!=4 || $item['status']!=5}
                            {$item['created_at']}
                            {else}
                            {/if}
                        </td>
                    </tr>
                    {/loop}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
    {$pager}
</div>

